package com.lyz.dataStructure.JianZhiOffer;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 21:29
 * @Description:
 **/

import java.util.Stack;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/6/18 21:29
 *@Description:
 **/
public class Test11 {

    Stack<Integer> in = new Stack<Integer>();
    Stack<Integer> out = new Stack<Integer>();

    public void push(int node) {
       if(in.isEmpty()){
           in.push(node);
       }
    }

    public int pop()throws Exception {
        if(out.isEmpty()){
            while (!in.isEmpty()){
                out.push(in.pop());
            }
        }
        if (out.isEmpty())
            throw new Exception("queue is empty");
       return out.pop();
    }

    public static void main(String[] args) {
        Test11 test11 = new Test11();
        test11.push(1);
        test11.push(2);
        test11.push(3);
        test11.push(4);

        System.out.println();
    }
}
